﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void YGRYLGB14(DataSet db)
        {
            try
            {/*<GPGART,GPGVAR,GPGFARBE,GPSPPART,GPFBPART,GPZWPART,GABLO,GABLB,GABBUCHDAT,INQTY,PRODIN ,OUTQTY, ADJQTY--> */
                DataTable dtSoruce = db.Tables["GABEW"];
                DataTable dtOutput = new DataTable();
                dtOutput.Columns.Add("GABLO", typeof(System.String));
                dtOutput.Columns.Add("GABLB", typeof(System.String));
                dtOutput.Columns.Add("GABBUCHDAT", typeof(System.String));
                dtOutput.Columns.Add("GPSPPART", typeof(System.String));
                dtOutput.Columns.Add("GPFBPART", typeof(System.String));
                dtOutput.Columns.Add("GPGART", typeof(System.String));               
                dtOutput.Columns.Add("GPGFARBE", typeof(System.String));
                dtOutput.Columns.Add("GPGVAR", typeof(System.String));
                dtOutput.Columns.Add("RINQTY", typeof(System.String));                                   
                dtOutput.Columns.Add("INQTY", typeof(System.String));
                dtOutput.Columns.Add("RPRODIN", typeof(System.String));
                dtOutput.Columns.Add("PRODIN", typeof(System.String));
                dtOutput.Columns.Add("ROUTQTY", typeof(System.String));
                dtOutput.Columns.Add("OUTQTY", typeof(System.String));
                dtOutput.Columns.Add("RADJQTY", typeof(System.String));
                dtOutput.Columns.Add("ADJQTY", typeof(System.String));
                dtOutput.Columns.Add("GPZWPART", typeof(System.String));
                dtOutput.Columns.Add("RINTOT", typeof(System.String));
                dtOutput.Columns.Add("INTOT", typeof(System.String));
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["GPGFARBE"] = GetGB2312Value(row["GPGFARBE"].ToString());
                    row["GPSPPART"] = GetGB2312Value(row["GPSPPART"].ToString());
                    row["GPFBPART"] = GetGB2312Value(row["GPFBPART"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 2, 1);

                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1);
                exAgent.BatchConvert2Number(2, 9, count + 1, 16);
                exAgent.BatchConvert2Number(2, 18, count + 1, 19);
                exAgent.SetCellValue(1, 1, "库");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}